package sample.plugin.rainbow.brackets;

import com.rapid.api.Platform;
import com.rapid.api.lang.engine.LanguageContext;
import com.rapid.api.lang.engine.LanguageEngine;
import com.rapid.api.lang.engine.highlight.HighlightProvider;
import com.rapid.api.project.service.LanguageManager;
import com.rapid.framework.program.android.app.AndroidPlugin;
import com.rapid.util.function.Consumer;

public class RainbowApplication extends AndroidPlugin {
    @Override
    public void activate() {
        Platform.getProjectFramework().forEachManager(projectManager -> {
            projectManager.withService(LanguageManager.class, languageManager -> {
                languageManager.forEachEngine(engine -> {
                    LanguageContext context = engine.getContext();
                    HighlightProvider originProvider = engine.getHighlight();
                    HighlightProvider highlightProvider = new RainbowHighlightProvider(context, originProvider);
                    engine.setHighlight(highlightProvider);
                });
            });
        });
    }
}
